.text
.global main

main:
	# 1) call BIOS print string "It's bootblock!"
	dla		$a0, msg 			               # load msg address as parameter in a0
	ld		$t1, printstr		             # load func printstr address to $t0
	jalr	$t1  			                   # jump to printstr 

	# 2) call BIOS read kernel in SD card
  dli    $a0, 0xffffffffa0800000          # (re-locate)
  li    $a1, 0x200                  # offset = 200
  li    $a2, 0x200                  # load kernel size into a2
  
  dli    $ra, 0xfffffffa0800000   # (re-locate)
  ld     $t1, read_sd_card          # load func read_sd_card address to $t1
  j      $t1                        # jump to read_sd_card(re-locate)
	
  # 3) jump to kernel
	 

# 4) while(1) --> stop here
stop:
	j stop

.data

msg: .ascii "It's a bootloader...\n"

# 1. PMON read SD card function address
# read_sd_card();
read_sd_card: .dword 0xffffffff8f0d5e10

# 2. PMON print string function address
# printstr(char *string)
printstr: .dword 0xffffffff8f0d5534

# 3. PMON print char function address
# printch(char ch)
printch: .dword 0xffffffff8f0d5570

# 4. kernel address (move kernel to here ~)
kernel: .dword 0xffffffffa0800200

# 5. kernel main address (jmp here to start kernel main!)
kernel_main: .dword 0xffffffffa0800200
